//
//  MappingProvider.m
//  FliqFlicks
//
//  Created by EJ Lacap on 1/12/15.
//  Copyright (c) 2015 Lexnus. All rights reserved.
//

#import "MappingProvider.h"
#import "Flick.h"

@implementation MappingProvider

+ (RKEntityMapping *) flickMapping {
    // Create an object mapping.
    RKManagedObjectStore *managedObjectStore = [RKManagedObjectStore defaultStore];
    RKEntityMapping *entityMapping = [RKEntityMapping mappingForEntityForName:@"Flick" inManagedObjectStore:managedObjectStore];
    [entityMapping addAttributeMappingsFromDictionary:@{
                                                        @"id": @"flickId",
                                                        @"original_title": @"originalTitle",
                                                        @"release_date": @"releaseDate",
                                                        @"poster_path": @"posterPath",
                                                        @"popularity": @"popularity",
                                                        @"title": @"flickTitle",
                                                        @"vote_average": @"voteAverage",
                                                        @"vote_count": @"voteCount"
                                                        }];
    entityMapping.identificationAttributes = @[ @"flickId" ];

    [RKEntityMapping class];
    NSDateFormatter* dateFormatter = [NSDateFormatter new];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
    [[RKValueTransformer defaultValueTransformer] addValueTransformer:dateFormatter];
    return entityMapping;
}

@end
